import { LGXEnums } from '../sysenum.js'
import LXCOM from '../common.js'
import utilfuncs from '../tools/utilfuncs.js';
var funcs = utilfuncs.UtilFuncs;

import { LGXMathTool } from '../tools/math/lgxmathtool.js';
import { CoordTRFUtil } from '../tools/coordtool.js';

var posMode = LGXEnums.LGXPosMode;
class AbstractPos {
    constructor() {
        this.posType = posMode.point_mode;
    }
    clone(srcpos) { }
    createCopyPos(offset) { }
    offset(x, y) { }
    scale(basePt, sx, sy) { }

    mirror(stPt, nextPt) { }
    mirrorCopy(stPt, nextPt) { }
    getFeaturePt(tFeaturePTLst, transformInfo) { }

    convertPt2World(pt, transformInfo) {
        let featurePT = pt;
        if (transformInfo) {
            featurePT = CoordTRFUtil.transLocalPt2World(pt, 0, transformInfo);
        }
        return featurePT;
    }
}

class PointPos extends AbstractPos {
    constructor() {
        super();
        this.x = 0;
        this.y = 0;
        super.posType = posMode.point_mode;
    }
    clone(src) {
        this.x = src.x;
        this.y = src.y;
        this.posType = src.posType;
    }

    createCopyPos(offset) {
        var dst = new PointPos();
        dst.clone(this);
        dst.x += offset.x;
        dst.y += offset.y;
        return dst;
    }

    offset(x, y) {
        this.x += x;
        this.y += y;
    }
    getCnt() {
        return { x: this.x, y: this.y };
    }


    getFeaturePt(tFeaturePTLst, transformInfo) {
        let featurePT = { x: this.x, y: this.y };
        if (transformInfo) {
            featurePT = this.convertPt2World(featurePT, transformInfo);
        }
        tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.center });
    }

    scale(basePt, sx, sy) {
        LGXMathTool.scale(this, basePt, sx, sy);
    }
}

class MultiPos extends AbstractPos {
    constructor() {
        super();
        this.posList = new Array();
        super.posType = posMode.multiPt_Mode;
    }
    clone(src) {
        this.clear();
        this.posType = src.posType;
        for (var i in src.posList) {
            var pt = src.posList[i];
            var newpt = new LXCOM.LGXPoint();
            newpt.clone(pt);
            this.posList.push(newpt);
        }
    }

    addPoint(pt) {
        var nCount = this.posList.length;
        if (nCount == 0) {
            var point = new LXCOM.LGXPoint();
            point.clone(pt);
            this.posList.push(point);
        }
        else {
            var point = new LXCOM.LGXPoint();
            point.clone(pt);
            this.posList.push(point);
        }
    }

    createCopyPos(offset) {
        var dst = new MultiPos();
        dst.clone(this);
        for (var idx in dst.posList) {
            var pt = dst.posList[idx];
            pt.x += offset.x;
            pt.y += offset.y;
        }
        return dst;
    }

    getZone() {
        var rect = new LXCOM.LGXRect(0, 0, 0, 0);
        var lenth = this.posList.length;
        var pt = this.posList[0];
        rect.left = pt.x;
        rect.right = pt.x;
        rect.top = pt.y;
        rect.bottom = pt.y;

        for (var i = 1; i < lenth; i++) {
            pt = this.posList[i];
            rect.left = Math.min(rect.left, pt.x);
            rect.right = Math.max(rect.right, pt.x);
            rect.bottom = Math.min(rect.bottom, pt.y);
            rect.top = Math.max(rect.top, pt.y);
        }
        return rect;
    }

    getCnt() {
        let rect = this.getZone();
        return rect.getCnt();
    }

    setPosByString(sx, sy) {
        this.clear();
        var sxCoordList = sx.split(";");
        var syCoordList = sy.split(";");

        for (var i = 0; i < sxCoordList.length; i++) {
            var s = sxCoordList[i];
            var x = parseFloat(s);
            s = syCoordList[i];
            var y = parseFloat(s);

            var point = new LXCOM.LGXPoint();
            point.x = x;
            point.y = y;
            this.posList.push(point);
        }
    }

    fromString(strPosition) {
        this.clear();
        var coordList = strPosition.split(";");

        for (var i = 0; i < coordList.length; i++) {
            var strPt = coordList[i];
            var tmplst = strPt.split(",");
            var x = parseFloat(tmplst[0]);
            var y = parseFloat(tmplst[1]);
            var point = new LXCOM.LGXPoint();
            point.x = x;
            point.y = y;
            this.posList.push(point);
        }
    }

    toString() {
        var strPosition = "";
        for (var i = 0; i < this.posList.length; i++) {
            var p = this.posList[i];
            var sx = p.x;
            var sy = p.y;
            if (i > 0)
                strPosition = strPosition + ";" + sx + "," + sy;
            else
                strPosition = sx + "," + sy;
        }
        return strPosition;
    }

    clear() {
        for (var i = 0; i < this.posList.length; i++) {
            var p = this.posList[i];
            p = null;
        }

        this.posList.length = 0;
    }

    offset(x, y) {
        for (var i = 0; i < this.posList.length; i++) {
            var p = this.posList[i];
            p.x += x;
            p.y += y;
        }
    }
    getHead() {
        return this.posList[0];
    }
    getNext2Head() {
        return this.posList[1];
    }
    getTail() {
        return this.posList[this.posList.length - 1];
    }
    getNext2Tail() {
        return this.posList[this.posList.length - 2];
    }

    getFeaturePt(tFeaturePTLst, transformInfo) {
        let posList = this.posList;
        let length = posList.length;
        for (let i = 0; i < length; i++) {
            let pt = posList[i];
            let featurePT = { x: pt.x, y: pt.y };
            if (transformInfo) {
                featurePT = this.convertPt2World(featurePT, transformInfo);
            }
            tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.end });
        }

        if (length > 1) {
            let prePt = posList[0];
            for (let i = 1; i < posList.length; i++) {
                let pCntPt = posList[i];
                let x = (prePt.x + pCntPt.x) / 2.0;
                let y = (prePt.y + pCntPt.y) / 2.0;
                let pt = { x, y };
                let featurePT = { x: pt.x, y: pt.y };
                if (transformInfo) {
                    featurePT = this.convertPt2World(featurePT, transformInfo);
                }
                tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.lineMid });
                prePt = pCntPt;
            }
        }
    }

    scale(basePt, sx, sy) {
        let posList = this.posList;
        for (let i = 0; i < posList.length; i++) {
            let pt = posList[i];
            LGXMathTool.scale(pt, basePt, sx, sy);
        }
    }
    calLenth() {
        let sumLenth = 0;
        let posList = this.posList;
        let ptCount = posList.length;
        let prePt = posList[0];
        for (let i = 1; i < ptCount; i++) {
            let pCntPt = posList[i];
            sumLenth += funcs.distancePoint(prePt, pCntPt, 1);
            prePt = pCntPt;
        }
        return sumLenth;
    }
}

class ArcPos extends AbstractPos {
    constructor() {
        super();
        this.x = 0;
        this.y = 0;
        this.stAngle = 0;
        this.endAngle = 270;
        this.radius = 0;
        super.posType = posMode.arc_mode;
        this.antiClockWise = true;//默认逆时针
    }
    clone(src) {
        this.posType = src.posType;
        this.x = src.x;
        this.y = src.y;
        this.stAngle = src.stAngle;
        this.endAngle = src.endAngle;
        this.radius = src.radius;
        this.antiClockWise = src.antiClockWise;
    }

    createCopyPos(offset) {
        var dst = new ArcPos();
        dst.clone(this);
        dst.x += offset.x;
        dst.y += offset.y;
        return dst;
    }

    offset(x, y) {
        this.x += x;
        this.y += y;
    }

    getCnt() {
        return { x: this.x, y: this.y };
    }

    fromString(strPosition) {
        let list = strPosition.split(",");
        if (list.length != 6) {
            return;
        }
        this.x = parseFloat(list[0]);
        this.y = parseFloat(list[1]);
        this.radius = parseFloat(list[2]);
        this.stAngle = parseFloat(list[3]);
        this.endAngle = parseFloat(list[4]);
        let flag = list[5];
        if (flag == "false") {
            this.antiClockWise = false;
        }
        else if (flag == "true") {
            this.antiClockWise = true;
        }
    }


    toString() {
        let strPosition = + this.x + ","
            + this.y + ","
            + this.radius + ","
            + this.stAngle + ","
            + this.endAngle + ","
            + this.antiClockWise;
        return strPosition;
    }

    getFeaturePt(tFeaturePTLst, transformInfo) {
        let x = this.x;
        let y = this.y;
        let pt = { x, y };
        let featurePT = { x: pt.x, y: pt.y };
        if (transformInfo) {
            featurePT = this.convertPt2World(featurePT, transformInfo);
        }
        tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.center });

        let arcPtInfo = funcs.getArcControlPoint(this);
        if (arcPtInfo) {
            featurePT = { x: arcPtInfo.stPoint.x, y: arcPtInfo.stPoint.y };
            if (transformInfo) {
                featurePT = this.convertPt2World(featurePT, transformInfo);
            }
            tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.end });

            featurePT = { x: arcPtInfo.endPoint.x, y: arcPtInfo.endPoint.y };
            if (transformInfo) {
                featurePT = this.convertPt2World(featurePT, transformInfo);
            }

            tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.end });

            featurePT = { x: arcPtInfo.midPoint.x, y: arcPtInfo.midPoint.y };
            if (transformInfo) {
                featurePT = this.convertPt2World(featurePT, transformInfo);
            }
            tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.lineMid });
        }
    }

    scale(basePt, sx, sy) {
        LGXMathTool.scale(this, basePt, sx, sy);
        this.radius *= sx;
    }

}

class CirclePos extends AbstractPos {
    constructor() {
        super();
        this.x = 0;
        this.y = 0;
        this.radius = 0;
        this.posType = posMode.circle_mode;
    }
    clone(src) {
        this.posType = src.posType;
        this.x = src.x;
        this.y = src.y;
        this.radius = src.radius;
    }

    createCopyPos(offset) {
        var dst = new CirclePos();
        dst.clone(this);
        dst.x += offset.x;
        dst.y += offset.y;
        return dst;
    }

    offset(x, y) {
        this.x += x;
        this.y += y;
    }

    getCnt() {
        return { x: this.x, y: this.y };
    }

    fromString(strPosition) {
        let list = strPosition.split(",");
        if (list.length != 5) {
            return;
        }
        this.x = parseFloat(list[0]);
        this.y = parseFloat(list[1]);
        this.radius = parseFloat(list[2]);
    }

    toString() {
        let strPosition = + this.x + ","
            + this.y + ","
            + this.radius;
        return strPosition;
    }

    scale(basePt, sx, sy) {
        LGXMathTool.scale(this, basePt, sx, sy);
        this.radius *= sx;
    }
}

class RectPos extends AbstractPos {
    constructor() {
        super();
        this.left = 0;
        this.top = 0;
        this.right = 0;
        this.bottom = 0;
        this.posType = posMode.rect_mode;
    }
    clone(src) {
        this.posType = src.posType;
        this.left = src.left;
        this.right = src.right;
        this.top = src.top;
        this.bottom = src.bottom;
    }

    createCopyPos(offset) {
        var dst = new RectPos();
        dst.clone(this);
        dst.left += offset.x;
        dst.top += offset.y;
        dst.right += offset.x;
        dst.bottom += offset.y;
        return dst;
    }

    offset(x, y) {
        this.left += x;
        this.top += y;
        this.right += x;
        this.bottom += y;
    }

    getCnt() {
        var x = (this.left + this.right) * 0.5;
        var y = (this.top + this.bottom) * 0.5;
        return { x, y };
    }

    getZone() {
        var rect = new LXCOM.LGXRect(0, 0, 0, 0);
        rect.left = this.left;
        rect.right = this.right;
        rect.top = this.top;
        rect.bottom = this.bottom;
        return rect;
    }

    fromString(str) {

    }

    toString() {

    }
}

class EllipseArcPos extends AbstractPos {
    constructor() {
        super();
        this.x = 0;
        this.y = 0;
        this.stAngle = 0;
        this.endAngle = 270;
        this.xRadius = 0;
        this.yRadius = 0;
        super.posType = posMode.ellipseArc_mode;
        this.antiClockWise = true;//默认逆时针
        this.rotDegree = 0;//长轴旋转角度，标准坐标系下为0
    }
    clone(src) {
        this.posType = src.posType;
        this.x = src.x;
        this.y = src.y;
        this.stAngle = src.stAngle;
        this.endAngle = src.endAngle;
        this.xRadius = src.xRadius;
        this.yRadius = src.yRadius;
        this.antiClockWise = src.antiClockWise;
        this.rotDegree = src.rotDegree;
    }

    createCopyPos(offset) {
        var dst = new EllipseArcPos();
        dst.clone(this);
        dst.x += offset.x;
        dst.y += offset.y;
        return dst;
    }

    offset(x, y) {
        this.x += x;
        this.y += y;
    }

    getCnt() {
        return { x: this.x, y: this.y };
    }

    fromString(strPosition) {
        let list = strPosition.split(",");
        if (list.length != 7) {
            return;
        }
        this.x = parseFloat(list[0]);
        this.y = parseFloat(list[1]);
        this.xRadius = parseFloat(list[2]);
        this.yRadius = parseFloat(list[3]);
        this.stAngle = parseFloat(list[4]);
        this.endAngle = parseFloat(list[5]);
        let flag = list[6];
        if (flag == "false") {
            this.antiClockWise = false;
        }
        else if (flag == "true") {
            this.antiClockWise = true;
        }
        this.rotDegree = parseFloat(list[6]);
    }


    toString() {
        let strPosition = + this.x + ","
            + this.y + ","
            + this.xRadius + ","
            + this.yRadius + ","
            + this.stAngle + ","
            + this.endAngle + ","
            + this.antiClockWise + ","
            + this.rotDegree;
        return strPosition;
    }

    getFeaturePt(tFeaturePTLst, transformInfo) {
        let x = this.x;
        let y = this.y;
        let pt = { x, y };
        let featurePT = { x: pt.x, y: pt.y };
        if (transformInfo) {
            featurePT = this.convertPt2World(featurePT, transformInfo);
        }
        tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.center });

        let arcPtInfo = funcs.getEllipseArcControlPoint(this);
        if (arcPtInfo) {

            featurePT = { x: arcPtInfo.stPoint.x, y: arcPtInfo.stPoint.y };
            if (transformInfo) {
                featurePT = this.convertPt2World(featurePT, transformInfo);
            }
            tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.end });

            featurePT = { x: arcPtInfo.endPoint.x, y: arcPtInfo.endPoint.y };
            if (transformInfo) {
                featurePT = this.convertPt2World(featurePT, transformInfo);
            }

            tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.end });

            featurePT = { x: arcPtInfo.midPoint.x, y: arcPtInfo.midPoint.y };
            if (transformInfo) {
                featurePT = this.convertPt2World(featurePT, transformInfo);
            }
            tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.lineMid });
        }
    }

    scale(basePt, sx, sy) {
        LGXMathTool.scale(this, basePt, sx, sy);
        this.xRadius *= sx;
        this.yRadius *= sy;
    }
}

class EllipsePos extends AbstractPos {
    constructor() {
        super();
        this.x = 0;
        this.y = 0;
        this.yRadius = 0;
        this.xRadius = 0;
        this.posType = posMode.ellipse_mode;
        this.rotDegree = 0;//长轴旋转角度，标准坐标系下为0
    }
    clone(src) {
        this.posType = src.posType;
        this.x = src.x;
        this.y = src.y;
        this.xRadius = src.xRadius;
        this.yRadius = src.yRadius;
        this.rotDegree = src.rotDegree;
    }

    createCopyPos(offset) {
        var dst = new EllipsePos();
        dst.clone(this);
        dst.x += offset.x;
        dst.y += offset.y;
        return dst;
    }

    offset(x, y) {
        this.x += x;
        this.y += y;
    }

    getCnt() {
        return { x: this.x, y: this.y };
    }

    fromString(strPosition) {
        let list = strPosition.split(",");
        if (list.length != 5) {
            return;
        }
        this.x = parseFloat(list[0]);
        this.y = parseFloat(list[1]);
        this.xRadius = parseFloat(list[2]);
        this.yRadius = parseFloat(list[3]);
        this.rotDegree = parseFloat(list[4]);
    }



    toString() {
        let strPosition = + this.x + ","
            + this.y + ","
            + this.xRadius + ","
            + this.yRadius + ","
            + this.rotDegree;
        return strPosition;
    }

    scale(basePt, sx, sy) {
        LGXMathTool.scale(this, basePt, sx, sy);
        this.xRadius *= sx;
        this.yRadius *= sy;
    }
}

class SplinePos extends AbstractPos {
    constructor() {
        super();
        this.posList = new Array();
        super.posType = posMode.spline_mode;
    }
    clone(src) {
        this.clear();
        this.posType = src.posType;
        for (var i in src.posList) {
            var pt = src.posList[i];
            var newpt = new LXCOM.LGXPoint();
            newpt.clone(pt);
            this.posList.push(newpt);
        }
    }

    addPoint(pt) {
        var nCount = this.posList.length;
        if (nCount == 0) {
            var point = new LXCOM.LGXPoint();
            point.clone(pt);
            this.posList.push(point);
        }
        else {
            var point = new LXCOM.LGXPoint();
            point.clone(pt);
            this.posList.push(point);
        }
    }

    createCopyPos(offset) {
        var dst = new SplinePos();
        dst.clone(this);
        for (var idx in dst.posList) {
            var pt = dst.posList[idx];
            pt.x += offset.x;
            pt.y += offset.y;
        }
        return dst;
    }

    getZone() {
        var rect = new LXCOM.LGXRect(0, 0, 0, 0);
        var lenth = this.posList.length;
        var pt = this.posList[0];
        rect.left = pt.x;
        rect.right = pt.x;
        rect.top = pt.y;
        rect.bottom = pt.y;

        for (var i = 1; i < lenth; i++) {
            pt = this.posList[i];
            rect.left = Math.min(rect.left, pt.x);
            rect.right = Math.max(rect.right, pt.x);
            rect.bottom = Math.min(rect.bottom, pt.y);
            rect.top = Math.max(rect.top, pt.y);
        }
        return rect;
    }

    getCnt() {
        let rect = this.getZone();
        return rect.getCnt();
    }

    setPosByString(sx, sy) {
        this.clear();
        var sxCoordList = sx.split(";");
        var syCoordList = sy.split(";");

        for (var i = 0; i < sxCoordList.length; i++) {
            var s = sxCoordList[i];
            var x = parseFloat(s);
            s = syCoordList[i];
            var y = parseFloat(s);

            var point = new LXCOM.LGXPoint();
            point.x = x;
            point.y = y;
            this.posList.push(point);
        }
    }

    fromString(strPosition) {
        this.clear();
        var coordList = strPosition.split(";");

        for (var i = 0; i < coordList.length; i++) {
            var strPt = coordList[i];
            var tmplst = strPt.split(",");
            var x = parseFloat(tmplst[0]);
            var y = parseFloat(tmplst[1]);
            var point = new LXCOM.LGXPoint();
            point.x = x;
            point.y = y;
            this.posList.push(point);
        }
    }

    toString() {
        var strPosition = "";
        for (var i = 0; i < this.posList.length; i++) {
            var p = this.posList[i];
            var sx = p.x.toString();
            var sy = p.y.toString();
            if (i > 0)
                strPosition = strPosition + ";" + sx + "," + sy;
            else
                strPosition = sx + "," + sy;
        }
        return strPosition;
    }

    clear() {
        for (var i = 0; i < this.posList.length; i++) {
            var p = this.posList[i];
            p = null;
        }

        this.posList.length = 0;
    }

    offset(x, y) {
        for (var i = 0; i < this.posList.length; i++) {
            var p = this.posList[i];
            p.x += x;
            p.y += y;
        }
    }
    getHead() {
        return this.posList[0];
    }
    getNext2Head() {
        return this.posList[1];
    }
    getTail() {
        return this.posList[this.posList.length - 1];
    }
    getNext2Tail() {
        return this.posList[this.posList.length - 2];
    }


    getFeaturePt(tFeaturePTLst, transformInfo) {
        let posList = this.posList;
        let length = posList.length;
        for (let i = 0; i < length; i++) {
            let pt = posList[i];
            let featurePT = { x: pt.x, y: pt.y };
            if (transformInfo) {
                featurePT = this.convertPt2World(pt, transformInfo);
            }
            tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.end });
        }

        if (length > 1) {
            let prePt = posList[0];
            for (let i = 1; i < posList.length; i++) {
                let pCntPt = posList[i];
                let x = (prePt.x + pCntPt.x) / 2.0;
                let y = (prePt.y + pCntPt.y) / 2.0;
                let pt = { x, y };
                let featurePT = { x: pt.x, y: pt.y };
                if (transformInfo) {
                    featurePT = this.convertPt2World(pt, transformInfo);
                }
                tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.lineMid });
                prePt = pCntPt;
            }
        }
    }

    scale(basePt, sx, sy) {
        let posList = this.posList;
        for (let i = 0; i < posList.length; i++) {
            let pt = posList[i];
            LGXMathTool.scale(pt, basePt, sx, sy);
        }
    }
}

class LWPolylinePos extends AbstractPos {
    constructor() {
        super();
        this.posList = new Array();
        super.posType = posMode.lwpolyline_mode;
    }
    clone(src) {
        this.clear();
        this.posType = src.posType;
        for (var i in src.posList) {
            var pt = src.posList[i];
            var newpt = new LXCOM.LGXPoint();
            newpt.clone(pt);
            this.posList.push(newpt);
        }
    }

    addPoint(pt) {
        var nCount = this.posList.length;
        if (nCount == 0) {
            var point = new LXCOM.LGXPoint();
            point.clone(pt);
            this.posList.push(point);
        }
        else {
            var point = new LXCOM.LGXPoint();
            point.clone(pt);
            this.posList.push(point);
        }
    }

    createCopyPos(offset) {
        var dst = new MultiPos();
        dst.clone(this);
        for (var idx in dst.posList) {
            var pt = dst.posList[idx];
            pt.x += offset.x;
            pt.y += offset.y;
        }
        return dst;
    }

    getZone() {
        var rect = new LXCOM.LGXRect(0, 0, 0, 0);
        var lenth = this.posList.length;
        var pt = this.posList[0];
        rect.left = pt.x;
        rect.right = pt.x;
        rect.top = pt.y;
        rect.bottom = pt.y;

        for (var i = 1; i < lenth; i++) {
            pt = this.posList[i];
            rect.left = Math.min(rect.left, pt.x);
            rect.right = Math.max(rect.right, pt.x);
            rect.bottom = Math.min(rect.bottom, pt.y);
            rect.top = Math.max(rect.top, pt.y);
        }
        return rect;
    }

    getCnt() {
        let rect = this.getZone();
        return rect.getCnt();
    }

    setPosByString(sx, sy) {
        this.clear();
        var sxCoordList = sx.split(";");
        var syCoordList = sy.split(";");

        for (var i = 0; i < sxCoordList.length; i++) {
            var s = sxCoordList[i];
            var x = parseFloat(s);
            s = syCoordList[i];
            var y = parseFloat(s);

            var point = new LXCOM.LGXPoint();
            point.x = x;
            point.y = y;
            this.posList.push(point);
        }
    }

    fromString(strPosition) {
        this.clear();
        var coordList = strPosition.split(";");

        for (var i = 0; i < coordList.length; i++) {
            var strPt = coordList[i];
            var tmplst = strPt.split(",");
            var x = parseFloat(tmplst[0]);
            var y = parseFloat(tmplst[1]);
            var point = new LXCOM.LGXPoint();
            point.x = x;
            point.y = y;
            this.posList.push(point);
        }
    }

    toString() {
        var strPosition = "";
        for (var i = 0; i < this.posList.length; i++) {
            var p = this.posList[i];
            var sx = p.x.toString();
            var sy = p.y.toString();
            if (i > 0)
                strPosition = strPosition + ";" + sx + "," + sy;
            else
                strPosition = sx + "," + sy;
        }
        return strPosition;
    }

    clear() {
        for (var i = 0; i < this.posList.length; i++) {
            var p = this.posList[i];
            p = null;
        }

        this.posList.length = 0;
    }

    offset(x, y) {
        for (var i = 0; i < this.posList.length; i++) {
            var p = this.posList[i];
            p.x += x;
            p.y += y;
        }
    }
    getHead() {
        return this.posList[0];
    }
    getNext2Head() {
        return this.posList[1];
    }
    getTail() {
        return this.posList[this.posList.length - 1];
    }
    getNext2Tail() {
        return this.posList[this.posList.length - 2];
    }


    getFeaturePt(tFeaturePTLst, transformInfo) {
        let posList = this.posList;
        let length = posList.length;
        for (let i = 0; i < length; i++) {
            let pt = posList[i];
            let featurePT = { x: pt.x, y: pt.y };
            if (transformInfo) {
                featurePT = this.convertPt2World(pt, transformInfo);
            }
            tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.end });
        }

        if (length > 1) {
            let prePt = posList[0];
            for (let i = 1; i < posList.length; i++) {
                let pCntPt = posList[i];
                let x = (prePt.x + pCntPt.x) / 2.0;
                let y = (prePt.y + pCntPt.y) / 2.0;
                let pt = { x, y };
                let featurePT = { x: pt.x, y: pt.y };
                if (transformInfo) {
                    featurePT = this.convertPt2World(pt, transformInfo);
                }
                tFeaturePTLst.push({ pt: featurePT, kind: LGXEnums.AuxPointKind.lineMid });
                prePt = pCntPt;
            }
        }
    }

    scale(basePt, sx, sy) {
        let posList = this.posList;
        for (let i = 0; i < posList.length; i++) {
            let pt = posList[i];
            LGXMathTool.scale(pt, basePt, sx, sy);
        }
    }
}


export default {
    AbstractPos, PointPos, MultiPos,
    ArcPos, CirclePos, RectPos, EllipseArcPos, EllipsePos, SplinePos, LWPolylinePos
}
